package com.rao.controller;


import com.rao.config.websecurity.permitcollect.PermitAnyOne;
import com.rao.core.startcollect.StartPrintUrlTag;
import com.rao.entity.VO.CommonResponseVO;
import com.rao.mideng.annotation.RaoLogAnno;
import com.rao.service.IClazzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 班级表 前端控制器
 * </p>
 *
 * @author rao3030
 * @since 2021-11-04
 */
@RestController
@RequestMapping("/clazz")
@Api(value = "班级相关的操作")
public class ClazzController {
    @Autowired
    private IClazzService iClazzService;

    @ApiOperation(value = "根据班级id查询班级的信息")
    @PreAuthorize("hasAnyRole('ADMIN')")
    @StartPrintUrlTag
    @RaoLogAnno
    @RequestMapping(path = "/oneByIdDetail/{id}", method = RequestMethod.GET)
    public CommonResponseVO oneByIdDetail(@PathVariable @NotNull(message = "请输入班级id") Integer id) {
        return CommonResponseVO.success(CommonResponseVO.SUCCESS_STATUS, "需要查询班级信息", iClazzService.oneByIdDetail(id));
    }

    @ApiOperation(value = "查询所有的班级信息")
    @PreAuthorize("hasAnyRole('ADMIN')")
    @StartPrintUrlTag
    @RaoLogAnno
    @RequestMapping(path = "/listAllDetail", method = RequestMethod.GET)
    public CommonResponseVO listAllDetail() {
        return CommonResponseVO.success(CommonResponseVO.SUCCESS_STATUS, "所有的班级信息", iClazzService.listAllDetail());
    }
}
